package com.ruoyi.project.user.dictKkuserInfo.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.user.dictKkuserInfo.domain.DictKkuserInfo;
import com.ruoyi.project.user.dictKkuserInfo.service.IDictKkuserInfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 用户信息Controller
 * 
 * @author shixiangwen
 * @date 2022-10-11
 */
@Controller
@RequestMapping("/user/dictKkuserInfo")
public class DictKkuserInfoController extends BaseController
{
    private String prefix = "user/dictKkuserInfo";

    @Autowired
    private IDictKkuserInfoService dictKkuserInfoService;

    @RequiresPermissions("user:dictKkuserInfo:view")
    @GetMapping()
    public String dictKkuserInfo()
    {
        return prefix + "/dictKkuserInfo";
    }

    /**
     * 查询用户信息列表
     */
    @RequiresPermissions("user:dictKkuserInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DictKkuserInfo dictKkuserInfo)
    {
        startPage();
        List<DictKkuserInfo> list = dictKkuserInfoService.selectDictKkuserInfoList(dictKkuserInfo);
        return getDataTable(list);
    }

    /**
     * 导出用户信息列表
     */
    @RequiresPermissions("user:dictKkuserInfo:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DictKkuserInfo dictKkuserInfo)
    {
        List<DictKkuserInfo> list = dictKkuserInfoService.selectDictKkuserInfoList(dictKkuserInfo);
        ExcelUtil<DictKkuserInfo> util = new ExcelUtil<DictKkuserInfo>(DictKkuserInfo.class);
        return util.exportExcel(list, "dictKkuserInfo");
    }

    /**
     * 新增用户信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用户信息
     */
    @RequiresPermissions("user:dictKkuserInfo:add")
    @Log(title = "用户信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DictKkuserInfo dictKkuserInfo)
    {
        return toAjax(dictKkuserInfoService.insertDictKkuserInfo(dictKkuserInfo));
    }

    /**
     * 修改用户信息
     */
    @GetMapping("/edit/{kkuid}")
    public String edit(@PathVariable("kkuid") Long kkuid, ModelMap mmap)
    {
        DictKkuserInfo dictKkuserInfo = dictKkuserInfoService.selectDictKkuserInfoById(kkuid);
        mmap.put("dictKkuserInfo", dictKkuserInfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户信息
     */
    @RequiresPermissions("user:dictKkuserInfo:edit")
    @Log(title = "用户信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DictKkuserInfo dictKkuserInfo)
    {
        return toAjax(dictKkuserInfoService.updateDictKkuserInfo(dictKkuserInfo));
    }

    /**
     * 删除用户信息
     */
    @RequiresPermissions("user:dictKkuserInfo:remove")
    @Log(title = "用户信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(dictKkuserInfoService.deleteDictKkuserInfoByIds(ids));
    }
}
